@extends('frontend/layouts/bootstrap')

@section('content')
<h1>Сэлбэгийн үнийн мэдээлэл оруулах</h1>

<div class="well well-small">
    <b>Part:</b> {{ $part->parts_name }}
@if($part->pickup_car_chassis_no )
    ({{ $part->pickup_car_chassis_no }})
@endif
    , <b>Purchase date:</b> {{ $part->purchase_date }}
</div>

{{ Form::open(array('route' => array('car_balance.parts.edit', $part->id))) }}

<table class="table table-bordered">
    <thead style="background-color: #f0f0f0;">
        <th>Payment type</th>
        <th>Payment date</th>
        <th title="Payment">入金</th>
        <th>Price</th>
        <th>Delivery</th>
        <th>Commission</th>
        <th>Fee (mongol)</th>
        <th>Comment</th>
    </thead>

    <tr>
        <td><select name="payment_type" id="payment_type">
                <option value="Cash" {{ $part->payment_type == 'Cash' ? 'selected' : '' }}>Cash</option>
                <option value="Yahoo" {{ $part->payment_type == 'Yahoo' ? 'selected' : '' }}>Yahoo</option>
                <option value="Bank" {{ $part->payment_type == 'Bank' ? 'selected' : '' }}>Bank</option>
            </select></td>
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'payment_date', 'value' => $part->payment_date))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'payment_commission', 'value' => $part->payment_commission))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'price', 'value' => $part->price))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'delivery_fee', 'value' => $part->delivery_fee))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'commission', 'value' => $part->commission))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'fee_mongol', 'value' => $part->fee_mongol))
        @include('nimo.domains.car_balance.Main._form_field', array('field'=>'comment', 'value' => $part->comment))
    </tr>
</table>

<button type="reset" class="btn btn-large btn-default">Reset</button>
<button type="submit" class="btn btn-large btn-success"><i class="icon-plus icon-white"></i> Бүртгэх</button> &nbsp;&nbsp;

{{ Form::close() }}
@stop


@section('pagescripts')
<!--page specific plugin scripts-->
<script type="text/javascript" >
    $(document).ready(function(){
        if($('input[name=purchase_date]').val() == '') {
            var d = new Date();

            var month = d.getMonth()+1;
            var day = d.getDate();

            var output = d.getFullYear() + '-' +
                (month<10 ? '0' : '') + month + '-' +
                (day<10 ? '0' : '') + day;

            $('input[name=purchase_date]').val(output);
        }
    });
</script>
@stop